package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.MallProductSpecs;
import com.sc.nft.mapper.MallProductSpecsMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * IP商城商品规格表(sc_mall_product_specs)数据DAO
 *
 * @author zxy
 * @since 2023-05-10 16:59:01
 * @description IP商城
 */
@Slf4j
@Repository
public class MallProductSpecsDao extends ServiceImpl<MallProductSpecsMapper, MallProductSpecs> {

    public List<MallProductSpecs> productSpecsList(Long productId) {
        LambdaQueryWrapper<MallProductSpecs> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MallProductSpecs::getProductId, productId);
        return baseMapper.selectList(wrapper);
    }

    public Boolean notHasSpecs(Long productId,List<Integer> apiProductIds){
        LambdaQueryWrapper<MallProductSpecs> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MallProductSpecs::getProductId, productId);
        wrapper.in(MallProductSpecs::getApiProductId, apiProductIds);
        Integer count = baseMapper.selectCount(wrapper);
        return count == 0 ? true :false;
    }

    public MallProductSpecs getByIdWithoutDeleted(Long specsId) {
        return baseMapper.getByIdWithoutDeleted(specsId);
    }
}